package activemq;

import javax.jms.Connection;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jms.Topic;

import utils.ActiveMq;

public class ActiveMqProducer {
	public void send(String message) throws JMSException {
		Connection connection = ActiveMq.getConnection();
		connection.start();
		Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
		Topic topic = session.createTopic(ActiveMq.TOPIC_NAME);
		MessageProducer producer = session.createProducer(topic);
		TextMessage textMessage = session.createTextMessage(message);
		producer.send(textMessage);
		producer.close();
		session.close();
		connection.close();
	}

}
